Data Types
The following is a list of datatypes available in MariaDB, which includes string, numeric, date/time, and large object datatypes.
String Datatypes
The following are the String Datatypes in MariaDB:
Data Type Syntax |
Maximum Size |
Explanation |
CHAR(size) |
Maximum size of 255 characters. |
Where size is the number of characters to store. Fixed-length strings. Space padded on right to equal size characters. |
VARCHAR(size) |
Maximum size of 255 characters. |
Where size is the number of characters to store. Variable-length string. |
TINYTEXT(size) |
Maximum size of 255 characters. |
Where size is the number of characters to store. |
TEXT(size) |
Maximum size of 65,535 characters. |
Where size is the number of characters to store. |
MEDIUMTEXT(size) |
Maximum size of 16,777,215 characters. |
Where size is the number of characters to store. |
LONGTEXT(size) |
Maximum size of 4GB or 4,294,967,295 characters. |
Where size is the number of characters to store. |
BINARY(size) |
Maximum size of 255 characters. |
Where size is the number of binary characters to store. Fixed-length strings. Space padded on right to equal size characters. |
VARBINARY(size) |
Maximum size of 255 characters. |
Where size is the number of characters to store. Variable-length string. |
Numeric Datatypes
The following are the Numeric Datatypes in MariaDB:
Data Type Syntax |
Maximum Size |
Explanation |
BIT |
Very small integer value that is equivalent to TINYINT(1). |
|
TINYINT(m) |
Very small integer value. |
|
SMALLINT(m) |
Small integer value. |
|
MEDIUMINT(m) |
Medium integer value. |
|
INT(m) |
Standard integer value. |
|
INTEGER(m) |
Standard integer value. |
This is a synonym for the INT datatype. |
BIGINT(m) |
Big integer value. |
|
DECIMAL(m,d) |
Unpacked fixed point number. |
Where m is the total digits and d is the number of digits after the decimal. |
DEC(m,d) |
Unpacked fixed point number. |
Where m is the total digits and d is the number of digits after the decimal. |
NUMERIC(m,d) |
Unpacked fixed-point number. |
Where m is the total digits and d is the number of digits after the decimal. |
FIXED(m,d) |
Unpacked fixed-point number. |
Where m is the total digits and d is the number of digits after the decimal. |
FLOAT(m,d) |
Single precision floating point number. |
Where m is the total digits and d is the number of digits after the decimal. |
DOUBLE(m,d) |
Double precision floating point number. |
Where m is the total digits and d is the number of digits after the decimal. |
DOUBLE PRECISION(m,d) |
Double precision floating point number. |
Where m is the total digits and d is the number of digits after the decimal. |
REAL(m,d) |
Double precision floating point number. |
Where m is the total digits and d is the number of digits after the decimal. |
FLOAT(p) |
Floating point number. |
Where p is the precision. |
BOOL |
Synonym for TINYINT(1) |
Treated as a boolean data type where a value of 0 is considered to be FALSE and any other value is considered to be TRUE. |
BOOLEAN |
Synonym for TINYINT(1) |
Treated as a boolean data type where a value of 0 is considered to be FALSE and any other value is considered to be TRUE. |
Date/Time Datatypes
The following are the Date/Time Datatypes in MariaDB:
Data Type Syntax |
Maximum Size |
Explanation |
DATE |
Values range from '1000-01-01' to '9999-12-31'. |
Displayed as 'YYYY-MM-DD'. |
DATETIME |
Values range from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. |
Displayed as 'YYYY-MM-DD HH:MM:SS'. |
TIMESTAMP(m) |
Values range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. |
Displayed as 'YYYY-MM-DD HH:MM:SS'. |
TIME |
Values range from '-838:59:59' to '838:59:59'. |
Displayed as 'HH:MM:SS'. |
YEAR[(2|4)] |
Year value as 2 digits or 4 digits. |
Default is 4 digits. |
Large Object (LOB) Datatypes
The following are the LOB Datatypes in MariaDB:
Data Type Syntax |
Maximum Size |
Explanation |
TINYBLOB |
Maximum size of 255 bytes. |
|
BLOB(size) |
Maximum size of 65,535 bytes. |
Where size is the number of characters to store |
MEDIUMBLOB |
Maximum size of 16,777,215 bytes. |
|
LONGTEXT |
Maximum size of 4GB or 4,294,967,295 characters. |